﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Hi_Baidu.Notify.NotifyObject;
using System.Collections;
using Hi_Baidu.Entry.CollectionObject;

namespace Hi_Baidu
{
    /// <summary>
    /// Win_AddFriend.xaml 的交互逻辑
    /// </summary>
    public partial class Win_AddFriend : Window,IMetaData,IPopWindowAction
    {
        private Notify.Notify NotifyObject;
        public Win_AddFriend()
        {
            InitializeComponent();
        }

        /// <summary>
        ///     添加好友窗口
        /// </summary>
        /// <param name="Key">唯一标示</param>
        /// <param name="NotifyObject">添加好友提示对象</param>
        public Win_AddFriend(String Key, Notify.Notify NotifyObject)
        {
            InitializeComponent();
            this.key = Key;
            this.NotifyObject = NotifyObject;
            this.Title = (NotifyObject as Notify_AddFriend).GetUsername() + " 邀请您加入好友";
            this.tb_NickName.Text = (NotifyObject as Notify_AddFriend).GetUsername();
            this.tb_Message.Text = "无留言";
            foreach (DictionaryEntry item in Globle.itemCollection.Members)
            {
                ComboBoxItem menuItem = new ComboBoxItem();
                menuItem.Content = (item.Value as Item).Name;
                menuItem.Tag = item.Key;
                this.cbx_Item.Items.Add(menuItem);
            }
            this.cbx_Item.SelectedIndex = 0;
        }

        private void AddFriend_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                this.DragMove();
            }
        }

        private void btn_OK_Copy_Click(object sender, RoutedEventArgs e)
        {
            (NotifyObject as Notify_AddFriend).Agreen((this.cbx_Item.SelectedItem as ComboBoxItem).Tag.ToString());
            this.DisposeToManager();
        }

        private void btn_Cancle_Click(object sender, RoutedEventArgs e)
        {
            (NotifyObject as Notify_AddFriend).Refuse();
            this.DisposeToManager();
        }

        #region IMetaData 成员

        private String key;
        public string Key
        {
            get
            {
                return key;
            }
            set
            {
                key = value;
            }
        }

        #endregion

        #region IPopWindowAction 成员

        public void DisposeToManager()
        {
            Globle.popWindowManager.Remove(this.key);
            this.Close();
        }

        #endregion
    }
}
